﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using Dapper;
using DapperExtensions;
using MaximServices.Data;
using MaximServices.Model;
using Microsoft.Extensions.Options;
using MySql.Data.MySqlClient;

namespace MaximServices.Repository
{
    public class SysuserRepository
    {
        private readonly DataBaseRepository _dbrsp;

        public SysuserRepository(DataBaseRepository dbrsp)
        {
            _dbrsp = dbrsp;
        }

        public void Dispose()
        {
            _dbrsp.Database.Dispose();
        }

        public Sysuser GetModel(string name)
        {
            try
            {
                var p = Predicates.Field<Sysuser>(f => f.UserName, Operator.Eq, name);
                var model = _dbrsp.Database.GetList<Sysuser>(p, null, null, null, false).FirstOrDefault();
                return model;
            }
            catch (Exception)
            {
                throw;
            }
        }
    }
}
